package problem.nc161;


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Solution {
    static class TreeNode {
        int val = 0;
        TreeNode left = null;
        TreeNode right = null;
        public TreeNode(int val) {
            this.val = val;
        }
    }

    List<Integer> list = new ArrayList<>();

    public int[] inorderTraversal (TreeNode root) {
        if(root == null){
            return new int[0];
        }

        inorderTraversal(root.left);
        list.add(root.val);
        inorderTraversal(root.right);

        if(list.size() == 0){
            return new int[0];
        }
        int[] arr = new int[list.size()];

        for(int i = 0;i<arr.length;i++) {
            arr[i] = list.get(i);
        }
        return arr;
    }
}
